
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "MqttSubscribe_Data.h"
#include "esp_log.h"


MqttSubscribe_Data_U MqttSubscribe_Data;


uint8_t* MqttSubscribe_Encode(MqttSubscribe_MsgID_E msgID, uint8_t length, uint8_t param[])
{
    if(sizeof(param) < MqttSubscribe_MsgLength) return;

    MqttSubscribe_Data.MqttSubscribe_Msg.MqttSubscribe_MsgID = msgID;
    MqttSubscribe_Data.MqttSubscribe_Msg.MqttSubscribe_BufLength = length;
    for (int i = 0; i < MqttSubscribe_MsgLength; i++)
    {
        MqttSubscribe_Data.MqttSubscribe_Msg.Param[i] = param[i];
    }
    
    return MqttSubscribe_Data.MqttSubscribe_Buf;
}

MqttSubscribe_Msg_S MqttSubscribe_Decode(uint8_t buf[])
{
    char* str = (const char *)buf;

    
    // for (int i = 0; (i < strlen(str)) && (i < (MqttSubscribe_MsgLength + 2)); i++)
    // {
        
    //     MqttSubscribe_Data.MqttSubscribe_Buf[i] = u8;
    // }
    
    return MqttSubscribe_Data.MqttSubscribe_Msg;
}

void MqttSubscribe_Reset(void)
{
    for (int i = 0; i < (MqttSubscribe_MsgLength + 4); i++)
    {
        MqttSubscribe_Data.MqttSubscribe_Buf[i] = 0;
    }
}
